///1.表单的加载
///1.按钮权限加载
///2.控件加载
///3.数据绑定
///4.节点数据必填，隐藏显示字段加载
///5.保存前的判断
///6.保存发起流程
///作者：刘亚平
/// <reference path="D:\工作资料\gongzuo\EAWP_MindrayAPP\MindrayApp\MindrayAPP.Web\Scripts/base.js" />  test
///完成日期：20161027
/// <reference path="D:\工作资料\Mindary.Mobile.WebApp\RTXWeb\MindrayAppNew\MindrayApp\MindrayAPP.Web\Scripts/jquery.min.js" />

window.processButton = {
    'btnStart': '<button class="btn btn-default" type="button" buttype="btnStart" onclick="processFlow.StartOperation(this)"><i class="fa fa-check"></i>&nbsp;&nbsp;<span class="bold" data-langid="text_app_submit">提交</span></button>',
    'btnSave': '<button class="btn btn-default" type="button" buttype="btnSave" onclick="processFlow.AssemblData(this)"><i class="fa fa-save"></i>&nbsp;&nbsp;<span class="bold" data-langid="text_app_storage">暂存</span></button>',
    'btnAbandon': '<button class="btn btn-default" type="button" buttype="btnAbandon"  onclick="processFlow.AbandonOperation(this)"><i class="fa fa-remove"></i>&nbsp;&nbsp;<span class="bold" data-langid="text_app_discard">废弃</span></button>',
    'btnCopySend': '<button class="btn btn-default" type="button" buttype="btnCopySend" onclick="processFlow.CCOperation(this)"><i class="fa fa-clone"></i>&nbsp;&nbsp;<span class="bold" data-langid="text_app_copy">抄送</span></button>',
    'btnSendback': '<button class="btn btn-default" type="button" buttype="btnSendback" onclick="processFlow.RejectOperation(this)"><i class="fa fa-reply-all"></i>&nbsp;&nbsp;<span class="bold" data-langid="text_app_reject">驳回</span></button>',
    'btnApproval': '<button class="btn btn-default" type="button" buttype="btnApproval" onclick="processFlow.ApprovalOperation(this)"><i class="fa fa-check-square-o"></i>&nbsp;&nbsp;<span class="bold" data-langid="text_app_agree">同意</span></button>',
    'btnTranfer': '<button class="btn btn-default" type="button" buttype="btnTranfer" onclick="processFlow.TurnOperation(this)"><i class="fa fa-random"></i>&nbsp;&nbsp;<span class="bold" data-langid="text_app_trans">转办</span></button>',
    'btnHastenWork': '<button class="btn btn-default" type="button" buttype="btnHastenWork" onclick="processFlow.TurnOperation(this)"><i class="fa fa-bullhorn"></i>&nbsp;&nbsp;<span class="bold" data-langid="text_app_press">催办</span></button>',
    'btnRepeal': '<button class="btn btn-default" type="button" buttype="btnRepeal" onclick="processFlow.AssemblData(this)"><i class="fa fa-trash-o"></i>&nbsp;&nbsp;<span class="bold" data-langid="text_app_repeal">撤销</span></button>',
    'btnStartQuery': '<button class="btn btn-default" type="button" buttype="btnStartQuery" onclick="processFlow.StartCommunication(this)"><i class="fa fa-edit"></i>&nbsp;&nbsp;<span class="bold" data-langid="text_app_comm">沟通</span></button>',
    'btnPrint': '<button class="btn btn-default" type="button" buttype="btnPrint" onclick="processFlow.OpenPrint(this)"><i class="fa fa-print"></i>&nbsp;&nbsp;<span class="bold" data-langid="text_app_print">打印</span></button>',
    'btnAnswerQuery': '<button class="btn btn-default" type="button" buttype="btnAnswerQuery" onclick="processFlow.AnswerCommunication(this)"><i class="fa fa-edit"></i>&nbsp;&nbsp;<span class="bold" data-langid="text_app_reply_comm">回复沟通</span></button>',
    'btnCancelQuery': '<button class="btn btn-default" type="button" buttype="btnCancelQuery"  onclick="processFlow.CancerCommunication(this)"><i class="fa fa-edit"></i>&nbsp;&nbsp;<span class="bold" data-langid="text_app_cancel_comm">取消沟通</span></button>',
    'btnAbandon_App': '<button class="btn btn-default" type="button" buttype="btnAbandon"  onclick="processFlow.AbandonOperation(this)"><i class="fa fa-trash-o"></i>&nbsp;&nbsp;<span class="bold" data-langid="text_app_discard">废弃</span></button>',
    'btnRepeal_App': '<button class="btn btn-default" type="button" buttype="btnRepeal"  onclick="processFlow.AssemblData(this);"><i class="fa fa-print"></i>&nbsp;&nbsp;<span class="bold" data-langid="text_app_repeal">撤销</span></button>',
    'btnCopyStart': '<button class="btn btn-default" type="button" buttype="btnCopyStart" onclick="processFlow.CopyStart(this);"><i class="fa fa-copy" aria-hidden="true"></i>&nbsp;&nbsp;<span class="bold" data-langid="text_app_copystart">复制草稿</span></button>',
    'btnFlowSkip': '<button class="btn btn-default" type="button" buttype="btnFlowSkip" onclick="processFlow.FlowSkip(this)" ><i class="glyphicon glyphicon-share-alt" aria-hidden="true"></i>&nbsp;&nbsp;<span class="bold" data-langid="text_app_flowskip">跳转</span></button>',
};
function ProcessFlow() {
    this.ProcID = $.query.get("processid") || '';
    this.ProcInsID = $.query.get("processinsid") || '';
    this.ActInsID = $.query.get("actinsid") || '';
    this.viewmodel = $.query.get("viewmodel") || '';
    this.Mobile = false;
}
///初始化
ProcessFlow.prototype.init = function () {
    isFlowDrawReadonly=true;
    var $this = this;
    this.GetProcAudit();
    this.LoadButton();
    if (!IsRead) {
        if (typeof( flowObj) != "undefined")
        flowObj.LoadDrawJson(flowChart, true);
        $("#div_content").SmartFromData("init", DataPermission);
        $this.HeadPermission();
        if (this.ProcInsID == '' && this.ActInsID == '' && this.viewmodel == '') {
            $("#Header_CreateUserName").val(userInfo.showUserName + "(" + userInfo.userNo + ")");
            $("#Header_CreateUserID").val(userInfo.userName);
            $("#Header_CreateDepName").val(userInfo.deptName);
            $("#Header_CreateDepID").val(userInfo.deptID);
            $("#Header_Document_Status").val("发起");
            $("#Header_applicantUser_DepName").val(userInfo.deptName);
            $("#Header_applicantUser_DepID").val(userInfo.deptID);
            $("#Header_CreateDate").val(userInfo.DateTime);
            SetFlowNumBer();
        }
        $("body").WmpButton();
        this.LoadData();

    } else {
        $("#div_content").SmartFromData("init", DataPermission);
        $("#Header_formSubTitle").attr("disabled", "disabled");
        if (typeof (flowObj)!="undefined")
        flowObj.LoadDrawJson(flowChart, true);
        this.LoadData();
        $("#div_content").SmartFromData("readonly");
        this.HeadPermission();
        $("body").WmpButton();
    }
    document.title=processName;
    $this.FormPrintLoad();


}
ProcessFlow.prototype.LoadButton = function () {
    if (operateType == "todo" || operateType == "draft" || operateType == "faqi") {
        $(OperatePermission).each(function () {
            if (this.IsVisible) {
                switch (this.OperateType) {
                    case "Save":
                        $(".action").append(window.processButton.btnSave);

                        break;
                    case "Start":
                        $(".action").append(window.processButton.btnStart);
                        break;
                    case "Sendback":
                        $(".action").append(window.processButton.btnSendback);
                        break;
                    case "Approval":
                        $(".action").append(window.processButton.btnApproval);
                        break;
                    case "Abandon_App":
                        $(".action").append(window.processButton.btnAbandon_App);
                        break;
                    case "Repeal_App":
                        $(".action").append(window.processButton.btnRepeal_App);
                        break;
                    case "StartQuery":
                        $(".action").append(window.processButton.btnStartQuery);
                        break;
                    case "HastenWork":
                        $(".action").append(window.processButton.btnHastenWork);
                        break;
                    case "CopySend":
                        $(".action").append(window.processButton.btnCopySend);
                        break;
                    case "Tranfer":
                        $(".action").append(window.processButton.btnTranfer);
                        break;
                    case "Extend1":
                        break;
                    case "Extend2":
                        break;
                }
            }
        });
    } else if (operateType == "start") {
        $(OperatePermission).each(function () {
            if (this.IsVisible && this.OperateType == "Abandon") {
                $(".action").append(window.processButton.btnAbandon_App);
            }
            if (this.IsVisible && this.OperateType == "Repeal") {
                $(".action").append(window.processButton.btnRepeal_App);
            }
        });
    }
    else if (operateType == "quxiaogoutong") {
        $(".action").append(window.processButton.btnCancelQuery);
    }
    else if (operateType == "goutong") {
        $(".action").append(window.processButton.btnAnswerQuery);
    }
    $(".action").append(window.processButton.btnPrint);
    if ($(".action").find("button").length > 0) {
        topheight = 123;
    }

}
ProcessFlow.prototype.LoadData = function () {
    if (FromData["Header_formSubTitle"] != undefined) {
        $("#Header_formSubTitle").val(FromData.Header_formSubTitle);
        $("#Header_formNumber").val(FromData.Header_formNumber);
        $("#Header_applicantUser").WmpSelect("set", [{
            Text: FromData.Header_applicantUserShow,
            Value: FromData.Header_applicantUserID
        }]);
        $("#Header_CreateUserName").val(FromData.Header_CreateUserName);
        $("#Header_CreateUserID").val(FromData.Header_CreateUserID);
        $("#Header_CreateDepName").val(FromData.Header_CreateDepName);
        $("#Header_CreateDepID").val(FromData.Header_CreateDepID);
        $("#Header_applicantUser_DepName").val(FromData.Header_CreateDepName);
        $("#Header_applicantUser_DepID").val(FromData.Header_CreateDepID);
        $("#Header_CreateDate").val(FromData.Header_CreateDate);
        $("#div_content").SmartFromData("setdata", FromData);
        if (flowstatusName != "" && Number(flowstatus) == 2) {
            $("#Header_Document_Status").val(flowstatusName);
        }
        else {
            var ProcInsState = ["发起", "草稿", "处理中", "", "已完成", "已废弃", "已撤销", "待系统处理", "审批失败", "审批异常", "流程异常"];
            $("#Header_Document_Status").val(ProcInsState[flowstatus]);
        }
    }
}
///头部权限控制方法
ProcessFlow.prototype.HeadPermission = function () {
    $("#Header_applicantUser").WmpSelect("user");
    $("#Header_applicantUser").WmpSelect("set", [{ Text: userInfo.userName, Value: userInfo.userNo }]);
    if (DataPermission["Header_formSubTitle"] != undefined) {
        if (DataPermission["Header_formSubTitle"].Read == false) {
            $("#Header_formSubTitle").hide();
        }
        if (DataPermission["Header_formSubTitle"].Write == false) {
            $("#Header_formSubTitle").attr("disabled", "disabled");
        }
        if (DataPermission["Header_formSubTitle"].Required == true) {
            $("#Header_formSubTitle").parent().addClass("flowrequired");
        }
        if (DataPermission["Header_applicantUserShow"].Read == false) {
            $("#Header_applicantUser").hide();
        }
        if (DataPermission["Header_applicantUserShow"].Write == false) {
            $("#Header_applicantUser").WmpSelect("disabled");
        }
        if (DataPermission["Header_applicantUserShow"].Required == true) {
            $("#Header_applicantUser").parent().addClass("flowrequired");
        }
    }
}

//获取审计信息并绑定审计信息
ProcessFlow.prototype.GetProcAudit = function () {
    if (this.ProcInsID != undefined) {
        AJAXAPI('/tappProcaudit/GetProcAudit', { procinstanceid: this.ProcInsID }, function (d) {
            if (d.data != null && d.data.length != undefined) {
                var current_data = { rows: [] };
                var history_data = { rows: [] };
                $(d.data).each(function (index, item) {
                    var ActName = item.fapprovelaction;
                    var Descr = item.fapproveldescr;
                    if (item.iscurrent) {
                        item.Index = d.data.length;
                        current_data.rows.push(item);
                    } else {
                        history_data.rows.push(item);
                    }


                });

                if (current_data.rows.length == 0) {
                    $("#current_record_table").hide();
                } else {
                    $("#current_record_table tbody").append($("#current_approvalrecord_tmpl").tmpl(current_data));
                }

                $("#history_record_table tbody").append($("#history_approvalrecord_tmpl").tmpl(history_data));

                TransAll("#current_record_table,#history_record_table");

                var first = middle = last = '';
                for (var idex = d.data.length - 1; idex >= 0; idex--) {
                    var $this = d.data[idex];
                    if ($this.iscurrent == true) {
                        first += '<li>';
                        first += '<div class="item">';
                        first += '<i class="arrow"></i>';
                        first += '<i class="curdot"></i>';
                        first += '<div class="item_line wbox"><em data-langid="text_wmp_cur_step">当前步骤</em><span class="wbox-flex1">' + $this.factname + '</span></div>';
                        first += '<div class="item_line wbox"><em data-langid="text_wmp_approver">审批人</em><span class="wbox-flex1">' + $this.fapproversname + '</span></div>';
                        first += '<div class="item_line wbox"><em data-langid="text_wmp_action">动作</em><span class="wbox-flex1">' + ($this.fapprovelaction == null ? "" : $this.fapprovelaction) + '</span></div>';
                        first += '<div class="item_line wbox"><em data-langid="text_wmp_examine_opt">审批意见</em><span class="wbox-flex1">' + ($this.fapproveldescr == null ? "" : $this.fapproveldescr) + '</span></div>';
                        first += '<div class="item_line wbox"><em data-langid="text_wmp_arrival_time">到达时间</em><span class="wbox-flex1">' + ($this.factopendate == null ? "" : $this.factopendate) + '</span></div>';
                        first += '<div class="item_line wbox"><em data-langid="text_wmp_approval_time">审批时间</em><span class="wbox-flex1">' + ($this.factfishdate == null ? "" : $this.factfishdate) + '</span></div>';
                        first += '</div>';
                        first += '</li>';
                    }
                    else if ($this.fapprovelaction == "发起" || $this.fapprovelaction == "Start") {
                        last += '<li>';
                        last += '<div class="item">';
                        last += '<i class="arrow"></i>';
                        last += '<i class="dot"></i>';
                        last += '<div class="item_line wbox"><em>发起</em><span class="wbox-flex1"></span></div>';
                        last += '<div class="item_line wbox"><em data-langid="text_wmp_proposer">申请人</em><span class="wbox-flex1">' + $this.fapproversname + '</span></div>';
                        last += '<div class="item_line wbox"><em data-langid="text_wmp_action">动作</em><span class="wbox-flex1">' + $this.fapprovelaction + '</span></div>';
                        last += '<div class="item_line wbox"><em data-langid="text_wmp_apply_time">申请时间</em><span class="wbox-flex1">' + $this.fcreationdate + '</span></div>';
                        last += '</div>';
                        last += '</li>';
                    } else {
                        middle += '<li>';
                        middle += '<div class="item">';
                        middle += '<i class="arrow"></i>';
                        middle += '<i class="dot"></i>';
                        middle += '<div class="item_line wbox"><em data-langid="text_wmp_approval_step">审批步骤</em><span class="wbox-flex1">' + $this.factname + '</span></div>';
                        if ($this.fapprovelaction == "System CC" || $this.fapprovelaction == "系统抄送" || $this.fapprovelaction == "System Cc") {
                            middle += '<div class="item_line wbox"><em data-langid="text_wmp_approver">审批人</em><span class="wbox-flex1">System</span></div>';
                        } else {
                            middle += '<div class="item_line wbox"><em data-langid="text_wmp_approver">审批人</em><span class="wbox-flex1">' + $this.fapproversname + '</span></div>';
                        }
                        middle += '<div class="item_line wbox"><em data-langid="text_wmp_action">动作</em><span class="wbox-flex1">' + $this.fapprovelaction + '</span></div>';
                        middle += '<div class="item_line wbox"><em data-langid="text_wmp_examine_opt">审批意见</em><span class="wbox-flex1">' + $this.fapproveldescr + '</span></div>';
                        middle += '<div class="item_line wbox"><em data-langid="text_wmp_arrival_time">到达时间</em><span class="wbox-flex1">' + ($this.factopendate == null ? "" : $this.factopendate) + '</span></div>';
                        middle += '<div class="item_line wbox"><em data-langid="text_wmp_approval_time">审批时间</em><span class="wbox-flex1">' + ($this.factfishdate == null ? "" : $this.factfishdate) + '</span></div>';
                        middle += '</div>';
                        middle += '</li>';
                    }
                }
                $("ul#record_ul").html(first + middle + last);

                TransAll("ul#record_ul, .trans-all");

                setTimeout(function () {
                    if (!Mobile) {
                        new IScroll('#approve_record_wrapper', {
                            preventDefault: true, click: true, mouseWheel: true, scrollbars: true, interactiveScrollbars: true, scrollX: false, scrollY: true
                        });
                    } else {
                        $("#approve_record_scroller").css("height", ($("#record_ul").height() + 10 + 10 + "px"));
                        $("#processfromtab").hide();
                        // new JRoll("#approve_record_wrapper", {
                        //     scrollX: false,
                        //     scrollY: true,
                        //     scrollBarY: true,
                        //     scrollBarFade: true
                        // });
                    }

                }, 100);
            }
        }, undefined, false);

        $(".viewAprRecord").click(function () {
            filterheight();
            $("#resFilterWrap").addClass("filter-show");
            $(".masklayer").show();
        });
        $("#resFilterWrap .close-btn,.masklayer").click(function () {
            removeheight();
            $("#resFilterWrap").removeClass("filter-show");
            $('.masklayer').hide();
        });
    } else {
        $(".viewAprRecord").remove();
    }
}
ProcessFlow.prototype.FormPrintLoad = function () {
    if ($.query.get("viewmodel") == "Print") {
    var thisData = this;
    setTimeout(function () {
        

            //if (wmpAllObj.Print && wmpAllObj.Print.Before && $.isFunction(wmpAllObj.Print.Before)) {
            //    /*存在打印前的回调事件*/
            //    wmpAllObj.Print.Before();
            //}
        $(".form-title h2").text(thisData.FProcName);
            //document.title = thisData.FProcName;
            //$(".form-title h2").html(thisData.FProcName);
            //if (window.Lang[thisData.FProcName] == undefined) {
            //    $(".form-title h2").text(thisData.FProcName);
            //    document.title = thisData.FProcName;
            //} else {
            //    $(".form-title h2").text(window.Lang[thisData.FProcName]);
            //    document.title = window.Lang[thisData.FProcName];
            //}

            //if ($("#Header_CreateUserName").length > 0 && $("#Header_applicantUser > input").length > 0) {
            //    $("#Header_CreateUserName").val($("#Header_CreateUserName").val().split('(')[0]);/*打印去除工号显示*/
            //    $("#Header_applicantUser > input").val($("#Header_applicantUser > input").val().split('(')[0]);/*打印去除工号显示*/
            //}

            //检查对应的表单是否要求保持折叠状态
            //var hideboxes = getQueryString("hideboxes");
            //var arrHidebox = [];
            //if ($.trim(hideboxes) != "") {
            //    arrHidebox = hideboxes.split("|");
            //}
            //for (var iHidebox = 0; iHidebox < arrHidebox.length; iHidebox++) {
            //    var boxId = arrHidebox[iHidebox];
            //    var box = $("#" + boxId).find(".detail-content,.wbox-content-right");
            //    box.remove();
            //}

            /*检测对应表单是否存在tab结构，如果存在，则直接将对应可现实的tab进行展开显示*/
            if ($(".nav.nav-tabs.wmp-tabs").length > 0) {
                $(".nav.nav-tabs.wmp-tabs").each(function () {
                    var $li = $(this).find("li");
                    $li.each(function () {
                        var target = $(this).find("a").attr("href");
                        if (!$(this).is(":visible")) {
                            $(target).remove();
                            return true;
                        }
                        target && $(target).show();
                    });

                    $(this).remove();
                });
            }

            $("[print='hidden']").remove();
            $("[type='xselector']").WmpSelect("readonly");
            $("[type='select']").WmpSelectBox("readonly");
            $("[type]").each(function (i) {
                switch ($(this).attr("type")) {
                    case "text":
                    case "number":
                    case "email":
                    case "month":
                    case "url":
                        if (!$(this).is(':visible')) {
                            $(this).replaceWith("");
                        } else {
                            if ($(this).parent().hasClass("form-group")) {
                                $(this).parent().replaceWith("<p class='mulit_line'><span>" + $(this).val() + "</span></p>");
                            } else {
                                $(this).replaceWith("<p class='mulit_line'><span>" + $(this).val() + "</span></p>");
                            }
                        }
                        break;
                    case "select":
                        if (!$(this).is(':visible')) {
                            $(this).parent().replaceWith("");
                        } else {
                            $(this).parent().replaceWith("<p class='mulit_line'><span>" + $(this).find("option:selected").text() + "</span></p>");
                        }
                        break;
                    case "radioList":
                        var text = $(this).find("a.checked").parent().text() || "";
                        var hasinput = $(this).find("input[type='text']");
                        if (hasinput.length == 1 && hasinput.is(':visible')) {
                            text += " " + hasinput.val().trim();
                        }
                        $(this).html("");
                        $(this).append("<p class='mulit_line'><span>" + text + "</span></p>");
                        break;
                    case "checkboxlist":
                        var text = "";
                        $(this).find("a.checked").each(function (i) {
                            text = text == "" ? $(this).parent().text() : text + ";" + $(this).parent().text();
                        });
                        $(this).html("");
                        $(this).append("<p class='mulit_line'><span>" + text + "</span></p>")
                        break;
                    case "Attachment":
                        $(this).find("button").remove();
                        break;
                    case "datalist":
                        $(this).find("button").remove();
                        var operate = $(this).find("th:eq(0)").html();
                        var filed = $(this).find("th:eq(0)").attr("filed");
                        if (filed == "Opration" || operate == "Operation" || operate == "operation" || operate == "操作") {
                            $(this).find("thead tr th:eq(0)").remove();
                            $(this).find("tbody tr").find("td:eq(0)").remove();
                            $(this).find("tfoot tr").find("td:eq(0)").remove();

                            if ($(this).find("tfoot").length > 0) {
                                if ($(this).find("tfoot td[colspan]").length > 0) {
                                    var _val = $(this).find("tfoot td[colspan]").first().attr("colspan");
                                    $(this).find("tfoot td[colspan]").first().attr("colspan", (parseInt(_val) - 1));
                                }
                            }
                        }
                        $(this).find("[filed='ckeckradio']").remove();
                        break;
                    case "xselector":
                        $(this).WmpSelect("disabled");
                        break;
                    default: break;

                }
            });

            var reg = new RegExp("\n", "g");
            $("textarea").each(function (i) {
                var str = $(this).val().trim();
                str = str.replace(reg, "<br/><br/>");
                $(this).replaceWith("<p class='mulit_line'><span>" + str + "</span></p>");
            });

            $("a").each(function (i) {
                if ($(this).parents(".border-content[data-print-checkbox='1']").length > 0) {
                    return;
                }

                if ($(this).hasClass("arrow_telescopic")) {
                    $(this).remove();
                    return;
                }

                if ($(this).parents("td").length > 0 || $(this).parents("th").length > 0) {
                    return;
                }

                $(this).replaceWith("<p class='mulit_line'><span>" + $(this).text() + "</span></p>");
            })
            $(".selector_collapse").hide();

            $("div[tab-content-container='true']").removeClass("hide").show();

            $(".detail-content").each(function () {
                if (!$(this).is(":visible")) { return true; }
                var $table = $(this).find("table");

                $table.find("th:hidden,td:hidden").remove();

                $table.find("tr,th,td").removeAttr("class").removeAttr("style");

                $table.find("th,td").each(function () {
                    if ($(this).find(".footable-ickeck").length > 0) {
                        if ($(this).find(".footable-ickeck.checked").length > 0) {
                            $(this).html("<input type=\"checkbox\" checked=\"checked\" disabled />");
                        } else {
                            $(this).html("<input type=\"checkbox\" disabled />");
                        }
                    } else if ($(this).find(".footable-iradio").length > 0) {
                        if ($(this).find(".footable-iradio.checked").length > 0) {
                            $(this).html("<input type=\"radio\" checked=\"checked\"  disabled />");
                        } else {
                            $(this).html("<input type=\"radio\"  disabled />");
                        }
                    }
                    else if ($(this).find("select").length > 0) {
                        /*处理下拉框*/
                        var _val = $(this).find("select option:selected").text();
                        $(this).html(_val);
                    } else {
                        $(this).html($(this).text().trim());
                    }
                });

                var tableHtml = "";
                var title = $(this).parents(".wbox-fix:first").find(".detail-title").text();
                if (!title) {
                    title = $(this).parents(".wbox-fix:first").attr("title");
                    if (!title) {
                        title = $(this).parents(".wbox-fix:first").find(".form_info").text();   
                    }
                }
                tableHtml += "<div class='table-title'><i class=\"fa fa-caret-square-o-right\"></i><span>" + title + "</span></div>";

                $table.each(function () {
                    var _table = $(this);

                    var theadHtml = _table.find("thead").html();
                    var tbodyHtml = _table.find("tbody").html();
                    var tfootHtml = _table.find("tfoot").html();

                    tableHtml += "<div>";

                    var tab_title = _table.attr("data-print-title");
                    if (tab_title) {
                        tableHtml += "<div class='sub-print-title'>" + tab_title + "</div>";
                    }

                    var table_pre = _table.attr("data-print-table-pre");
                    if (table_pre) {
                        var preHtml = "<div class='table-print-pre'>" + $("#" + table_pre).html() + "</div>";
                        tableHtml += preHtml;
                    }

                    tableHtml += "<table>";
                    if (theadHtml) {
                        tableHtml += "" + theadHtml + "";
                    }
                    if (tbodyHtml) {
                        tableHtml += "<tbody>" + tbodyHtml + "</tbody>";
                    }

                    if (tfootHtml) {
                        tableHtml += "<tbody>" + tfootHtml + "</tbody>";
                    }
                    tableHtml += "</table>";

                    var table_after = _table.attr("data-print-table-after");
                    if (table_after) {
                        var afterHtml = "<div class='table-print-after'>" + $("#" + table_after).html() + "</div>";
                        tableHtml += afterHtml;
                    }

                    tableHtml += "</div>";
                });

                $(this).parents(".wbox-fix:first").removeClass("wbox").html(tableHtml);
            });

            $(".selectcontrol:visible").each(function () {
                var text = "";
                if ($(this).find("option:selected").length > 0) {
                    $(this).find("option:selected").each(function () {
                        text += $(this).text() + ",";
                    });
                    if (text) {
                        text = text.substring(0, text.length - 1);
                    }
                }
                $(this).replaceWith(text);
            });

            var classReg = /col-sm-(\d+).*?col-xs-(\d+)/;
            $("div.border-title").each(function () {
                var classVal = $(this).attr("class");
                var result = classReg.exec(classVal);
                if (result && result.length > 2) {
                    var smVal = result[1];
                    var xsVal = result[2];

                    $(this).removeClass("col-xs-" + xsVal).addClass("col-xs-" + smVal);
                }

                $(this).removeClass("required");

                var html = "<div id=\"vertical_box\">";
                html += "<div id=\"vertical_box_sub\">";
                html += "<div id=\"vertical_box_container\">";
                html += "<p>" + $(this).text() + "</p>";
                html += "</div>";
                html += "</div>";
                html += "</div>";

                $(this).html(html);

                if ($(this).attr("print-define-height")) {
                    $(this).css("height", $(this).attr("print-define-height"));
                }
            });

            $("div.border-content").each(function () {
                var classVal = $(this).attr("class");
                var result = classReg.exec(classVal);
                if (result && result.length > 2) {
                    var smVal = result[1];
                    var xsVal = result[2];
                    $(this).removeClass("col-xs-" + xsVal).addClass("col-xs-" + smVal);
                } else if (classVal.indexOf('col-xs-hidden') > -1) {
                    var exReg = /col-sm-(\d+)/;
                    var exResult = exReg.exec(classVal);
                    if (exResult && exResult.length > 1) {
                        var smVal = exResult[1];
                        $(this).removeClass("col-xs-hidden").addClass("col-xs-" + smVal);
                    }
                }
                $(this).removeClass("required");
                //$(this).find(":hidden").remove();
                $(this).find(":hidden").not($("br")).remove();

                var text = $(this).text().trim();
                //富文本编辑器
                if ($(this).find(".edui-default").length > 0 && $(this).find(".edui-default").eq(0).attr("id") != "") {
                    text = UE.getEditor($(this).find(".edui-default").eq(0).attr("id")).getContent();
                }

                if ($(this).find("p.mulit_line").length > 0) {
                    if (text == $(this).find("p.mulit_line span").html()) {
                        text = $(this).find("p.mulit_line span").html();
                    }
                    //text = $(this).find("p.mulit_line span").html();
                }
                if ($(this).attr("data-print-checkbox")) {
                    text = "<input style='vertical-align: middle;margin-top: 0;width:16px;height:16px;' disabled type='checkbox' " + ($(this).find(".footable-ickeck.checked").length > 0 ? "checked" : "") + " />" + text;
                }

                text = text || "";

                var html = "<div id=\"vertical_box\">";
                html += "<div id=\"vertical_box_sub\">";
                html += "<div id=\"vertical_box_container\">";
                html += "<p>" + text + "</p>";
                html += "</div>";
                html += "</div>";
                html += "</div>";
                $(this).html(html);

                if ($(this).attr("print-define-height")) {
                    $(this).css("height", $(this).attr("print-define-height"));
                } else {
                    var oHeight = $(this).outerHeight(true);
                    var pHeight = $(this).prev().outerHeight(true);
                    if (oHeight >= pHeight+3) {
                        $(this).css("height", oHeight);
                        $(this).prev().css("height", oHeight);
                    } else {
                        $(this).css("height", pHeight);
                        $(this).prev().css("height", pHeight);
                    }
                }
            });

            var procinsid = thisData.ProcInsID;
            AJAXAPI('/tappProcaudit/GetProcAudit', { procinstanceid: thisData.ProcInsID }, function (d) {
                if (d && d.data.length > 0) {
                    //审批记录初始化前事件
                    if (typeof (beforeInitProcAudit) == "function") {
                        d.data = beforeInitProcAudit(d.data, procinsid, window.LangType);
                    }
                   
                    $("#audit_record tbody").append($("#ApprovalRecord-tmpl").tmpl(d));
                    TransAll("#audit_record");
                }
            });

            //if (wmpAllObj.Print && wmpAllObj.Print.After && $.isFunction(wmpAllObj.Print.After)) {
            //    /*存在打印后的回调事件*/
            //    wmpAllObj.Print.After();
            //}
       
    }, 500);
    }

}
ProcessFlow.prototype.OpenPrint = function () {
    if (typeof (this.ProcInsID) == "undefined" || this.ProcInsID == 0) {
        parent.ShowError("流程数据还未保存不能打印！");
        return;
    }
    window.open("/Flow/FormPrint?processinsid=" + this.ProcInsID + "&processid= " + this.ProcID + "&actinsid=56&viewmodel=Print" + "&hideboxes=");

}
///保存前判断必填项
ProcessFlow.prototype.SaveValidation = function (butobj) {
    if ($("#Header_formSubTitle").val() == "") {
        parent.ShowError("主题不能为空！");
        return false;
    }
    var applicatUser = $("#Header_applicantUser").WmpSelect("get");
    if (applicatUser.length == 0) {
        parent.ShowError("申请人不能为空！");
        return false;
    }
    if (!$("#div_content").SmartFromData("bizformdata", false, DataPermission)) {
        return false;
    }
    return true;
}
///审批按钮触发的事件
ProcessFlow.prototype.AssemblData = function (butObj, operationInfo) {
    var fromdata = $("#div_content").SmartFromData("getdata");
    fromdata.Header_formSubTitle = $("#Header_formSubTitle").val();
    fromdata.Header_formNumber = $("#Header_formNumber").val();
    fromdata.Header_CreateUserName = $("#Header_CreateUserName").val();
    fromdata.Header_CreateUserID = $("#Header_CreateUserID").val();
    fromdata.Header_CreateDepName = $("#Header_CreateDepName").val();
    fromdata.Header_CreateDepID = $("#Header_CreateDepID").val();
    fromdata.Header_Document_Status = $("#Header_Document_Status").val();
    var applicantUser = $("#Header_applicantUser").WmpSelect("get");
    fromdata.Header_applicantUserShow = applicantUser[0].name;
    fromdata.Header_applicantUserID = applicantUser[0].no;
    fromdata.Header_applicantUser_DepName = $("#Header_applicantUser_DepName").val();
    fromdata.Header_applicantUser_DepID = $("#Header_applicantUser_DepID").val();
    fromdata.Header_CreateDate = $("#Header_CreateDate").val();
    var param = {};
    param.operationInfo = operationInfo;
    param.ActionName = $(butObj).attr("butType");
    param.ActionType = $(butObj).attr("butType");
    param.ProcID = this.ProcID;
    param.ProcInsID = this.ProcInsID == '' ? 0 : this.ProcInsID;
    param.ActInsID = this.ActInsID == '' ? 0 : this.ActInsID;
    param.fromdata = fromdata;
    param.CureentUserID = userInfo.userNo;
    param.ActID = actid;
    param.PrevActName = "";///上一节点
    param.Procname = processName;

    AJAXAPI("/processins/HandleProcess", { process: JSON.stringify(param) }, function (d) {
        g_loading("close");
        if (d.success) {
            if ($(butObj).attr("butType") == "btnSave") {
                if (($("#Header_Document_Status").val() == "发起" || $("#Header_Document_Status").val() == "起草中")) {///如果是点击发起 第一次暂存则需要进行刷新一下页面
                    SuccessConfirm(function (index) {
                        if (typeof (ApproveSuccessAfter) == "function") {
                            var result = ApproveSuccessAfter();
                            if (result && result.preventDefault) {
                                return;
                            }
                        }
                        window.location.href = "/Flow/ProcessFrom?processid=" + param.ProcID + "&processinsid=" + d.data + "&actinsid=&viewmodel=draft";
                    });
                } else {
                    SuccessConfirm(function (index) {
                        if (typeof (ApproveSuccessAfter) == "function") {
                            ApproveSuccessAfter();
                        }
                    });
                }
            } else {
                SuccessConfirm(function () {
                    if (typeof (ApproveSuccessAfter) == "function") {
                        var result = ApproveSuccessAfter();
                        if (result && result.preventDefault) {
                            return;
                        }
                    }
                    if ($(butObj).attr("butType") != "btnCopySend") {
                        if ($(butObj).attr("butType") == "btnCancelQuery") {
                            window.location.href = "/Flow/ProcessFrom?processid=" + param.ProcID + "&processinsid=" + param.ProcInsID + "&actinsid=" + param.ActInsID + "&viewmodel=todo";
                        } else {
                            closewin();
                        }
                    }
                });

            }
        } else {
            ShowError(d.msg);
        }

    });
}
///审批动作
ProcessFlow.prototype.ApprovalOperation = function (butObj) {
    g_loading("close");
    var wmpobj = this;
    AJAX('/Content/Resources/html/ApprovedOperation.html', {
    }, function (d) {
        var html = d;
        var title = window.Lang['text_wmp_examine_opt'];//审批意见
        var dialog = null;
        layer.open({
            type: 1,
            anim: 'fadeIn',
            title: '<span>' + title + '</span>',
            content: html,
            success: function (layero, index) {
                TransAll(layero);
                dialog = $(layero);
                dialogResize(dialog, 600, 200);
                var index = dialog.attr("index");

                dialog.find("textarea").focus().blur();

                if (typeof (afterApprovalDialogShow) == "function") {
                    afterApprovalDialogShow(dialog.find("textarea"), dialog.find('.save'));
                }

                //保存
                dialog.find('.save').click(function () {
                    g_loading();
                    var operationInfo = {
                    };
                    operationInfo.ApprovedDes = dialog.find('.ApprovedDes').val().trim();
                    if (operationInfo.ApprovedDes) {
                        operationInfo.ApprovedDes = operationInfo.ApprovedDes.replace(/\n|\r\n/g, "<br>")
                    }
                    if (StringLength(operationInfo.ApprovedDes) > 1000) {
                        g_loading("close");
                        dialogOnlyConfirm("审批意见字符长度不能超过1000");
                        return;
                    }
                    wmpobj.AssemblData(butObj, operationInfo);
                });
            }
        });
    }, "GET", false);
}
///驳回动作
ProcessFlow.prototype.RejectText = "";
ProcessFlow.prototype.RejectOperation = function (butObj) {
    var wmpobj = this;
    AJAX('/Content/Resources/html/RejectOperation.html', {
    }, function (d) {
        var html = d;
        var title = window.LangMsg['msg_wmp_reject_opt'];//审批意见
        var dialog = null;
        layer.open({
            type: 1,
            anim: 'fadeIn',
            title: '<span>' + title + '</span>',
            content: html,
            success: function (layero, index) {
                TransAll(layero);
                dialog = $(layero);
                dialogResize(dialog, 600, 200);
                var index = dialog.attr("index");

                dialog.find("textarea").focus().blur();
                //保存
                dialog.find('.save').click(function () {
                    g_loading();
                    var operationInfo = {
                    };
                    operationInfo.ApprovedDes = dialog.find('.ApprovedDes').val().trim();
                    if (operationInfo.ApprovedDes) {
                        operationInfo.ApprovedDes = operationInfo.ApprovedDes.replace(/\n|\r\n/g, "<br>")
                    }
                    if (StringLength(operationInfo.ApprovedDes) > 1000) {
                        g_loading("close");
                        dialogOnlyConfirm("驳回原因字符长度不能超过1000");
                        return;
                    }
                    wmpobj.AssemblData(butObj, operationInfo);
                });
            }
        });
    }, "GET", false);
}

///发起动作
ProcessFlow.prototype.StartOperation = function (butObj) {
    if (processFlow.SaveValidation(butObj)) {
        processFlow.AssemblData(butObj);
    }

}

///复制草稿
ProcessFlow.prototype.CopyStart = function (butObj) {
    window.open("FormDefault?ProcBID=" + wmpAllObj.ProcBID + "&CopyProcInsID=" + wmpAllObj.ProcInsID);
}
///复制草稿加载数据模式
ProcessFlow.prototype.LoadCopyData = function () {
    var wmpObj = this;
    var CopyProcInsID = $.query.get("CopyProcInsID") || '';
    AJAXAPI('/wmp/api/WMPForm/GetWMPFormAndActPermissionInfoByProcIDActID', {
        ProcID: wmpObj.ProcID, ActInsID: wmpObj.ActInsID, ProcInstanceID: CopyProcInsID, OperateType: $.query.get("OperateType"), ActionType: $.query.get("ActionType"), IsRTX: $.query.get("IsRTX"), LangType: window.LangType
    }, function (d) {
        wmpObj.FData = d.FData;
        wmpObj.LoadWMPFormHtml();
    });
}


////转办动作
ProcessFlow.prototype.TurnOperation = function (butObj) {
    var wmpobj = this;
    AJAX('/Content/Resources/html/TurnOperation.html', {
    }, function (d) {
        var html = d;
        var title = window.LangMsg['msg_wmp_transmitting_opt'];
        var dialog = null;
        layer.open({
            type: 1,
            anim: 'fadeIn',
            title: '<span>' + title + '</span>',
            content: html,
            success: function (layero, index) {
                TransAll(layero);
                dialog = $(layero);
                dialogResize(dialog, 600, 246);
                var index = dialog.attr("index");

                if (Mobile) {
                    dialog.find(".approved_form_sel").css({ "padding-right": "5px", "margin-bottom": "3px" });
                    dialog.find('.wmpSingleUserSelector').replaceWith('<div class="selectcontrol"><input class="wmpSingleUserSelector" type="text" placeholder="请选择转办人"><i class="fa fa-caret-down"></i></div>');
                    dialog.find('.wmpSingleUserSelector').User();
                } else {
                    dialog.find('.wmpSingleUserSelector').WmpSelect("user");
                    dialog.find("textarea").focus().blur();
                }

                dialog.find('.save').click(function () {
                    if (dialog.find('.ApprovedDes').val().trim() == "") {
                        layerTip(window.LangMsg['msg_app_proccess_opt_is_not_null']);
                        return;
                    }
                    var userData;
                    if (Mobile) {
                        userData = dialog.find('.wmpSingleUserSelector').User("get");
                        if (userData.length > 0) {
                            $(userData).each(function (index, item) {
                                userData[index].name = item.user_name;
                                userData[index].no = item.user_no;
                            });
                        }
                    } else {
                        userData = dialog.find('.wmpSingleUserSelector').WmpSelect("get");
                    }
                    if (userData.length == 0) {
                        layerTip(window.LangMsg['msg_wmp_transmitting_person_is_not_null']);
                        return;
                    }
                    var operationInfo = {
                    };
                    operationInfo.ApprovedDes = dialog.find('.ApprovedDes').val();
                    if (operationInfo.ApprovedDes) {
                        operationInfo.ApprovedDes = operationInfo.ApprovedDes.replace(/\n|\r\n/g, "<br>")
                    }
                    if (StringLength(operationInfo.ApprovedDes) > 1000) {
                        dialogOnlyConfirm("转办意见长度不能超过1000");
                        return;
                    }
                    operationInfo.RedritUser = userData[0].no;
                    wmpobj.AssemblData(butObj, operationInfo);
                });
            }
        });
    }, "GET", false);
}

////抄送方法
ProcessFlow.prototype.CCOperation = function (butObj) {
    var wmpobj = this;
    AJAX('/Content/Resources/html/CCOperation.html', {
    }, function (d) {
        var html = d;
        var title = window.LangMsg['msg_wmp_copy_opt'];
        var dialog = null;
        layer.open({
            type: 1,
            anim: 'fadeIn',
            title: '<span>' + title + '</span>',
            content: html,
            success: function (layero, index) {
                TransAll(layero);
                dialog = $(layero);
                dialogResize(dialog, 600, 246);
                var index = dialog.attr("index");

                if (wmpobj.Mobile) {
                    dialog.find(".approved_form_sel").css({ "padding-right": "5px", "margin-bottom": "3px" });
                    dialog.find('.wmpSingleUserSelector').replaceWith('<div class="selectcontrol"><input class="wmpSingleUserSelector" type="text" placeholder="请选择抄送人"><i class="fa fa-caret-down"></i></div>');
                    dialog.find('.wmpSingleUserSelector').User({
                        multy: true
                    });
                } else {
                    dialog.find('.wmpSingleUserSelector').WmpSelect("user", {
                        multy: true
                    });
                    dialog.find("textarea").focus().blur();

                    if (typeof (afterCCShow) == "function") {
                        afterCcShow(dialog.find('.wmpSingleUserSelector'));
                        //dialog.find('.wmpSingleUserSelector').WmpSelect("set", [{ "name": "w", "no": "50215802" }]);
                    }
                }

                //保存
                dialog.find('.save').click(function () {
                    var userData = [];
                    if (wmpobj.Mobile) {
                        var userDatalist = dialog.find('.wmpSingleUserSelector').User("get");
                        if (userDatalist.length > 0) {
                            $(userDatalist).each(function (index, item) {
                                var obj = {};
                                obj.name = item.user_name;
                                obj.no = item.user_no;
                                userData.push(obj);
                            });
                        }
                    } else {
                        var userDatalist = dialog.find('.wmpSingleUserSelector').WmpSelect("get");
                        if (userDatalist.length > 0) {
                            $(userDatalist).each(function (index, item) {
                                var obj = {};
                                obj.name = item.name;
                                obj.no = item.no;
                                userData.push(obj);
                            });
                        }
                    }
                    if (userData.length == 0) {
                        layerTip(window.LangMsg['msg_wmp_cc_people_is_not_null']);
                        return;
                    }
                    var operationInfo = {
                    };
                    operationInfo.ApprovedDes = dialog.find('.ApprovedDes').val();
                    if (operationInfo.ApprovedDes) {
                        operationInfo.ApprovedDes =  operationInfo.ApprovedDes.replace(/\n|\r\n/g, "<br>");
                    }
                    if (StringLength(operationInfo.ApprovedDes) > 1000) {
                        dialogOnlyConfirm("抄送原因长度不能超过1000");
                        return;
                    }
                    operationInfo.copyUserlist = userData;
                    wmpobj.AssemblData(butObj, operationInfo);


                });
            }
        });
    }, "GET");
}
///沟通方法
ProcessFlow.prototype.CommunicationText = "";
ProcessFlow.prototype.StartCommunication = function (butObj) {
    var wmpobj = this;
    AJAX('/Content/Resources/html/StartCommunication.html', {
    }, function (d) {
        var html = d;
        var title = window.LangMsg['msg_wmp_sponsor_comm'];
        var dialog = null;
        var index = layer.open({
            type: 1,
            anim: 'fadeIn',
            title: '<span>' + title + '</span>',
            content: html,
            success: function (layero, index) {
                TransAll(layero);
                dialog = $(layero);
                //初始化驳回理由
                if ($.trim(wmpobj.CommunicationText) != "") {
                    dialog.find(".ApprovedDes").val(wmpobj.CommunicationText);
                }

                dialogResize(dialog, 600, 246);
                var index = dialog.attr("index");
                if (wmpobj.Mobile) {
                    dialog.find(".approved_form_sel").css({ "padding-right": "5px", "margin-bottom": "3px" });
                    dialog.find('.wmpSingleUserSelector').replaceWith('<div class="selectcontrol"><input class="wmpSingleUserSelector" type="text" placeholder="请选择沟通人"><i class="fa fa-caret-down"></i></div>');
                    dialog.find('.wmpSingleUserSelector').User({
                        multy: true
                    });
                } else {
                    dialog.find('.wmpSingleUserSelector').WmpSelect("user", {
                        multy: true
                    });
                    dialog.find("textarea").focus().blur();
                }
                //保存
                dialog.find('.save').click(function () {
                    if (dialog.find('.ApprovedDes').val() == "") {
                        layerTip(window.LangMsg['msg_wmp_comm_theme_is_not_null']);
                        return;
                    }
                    var userData = [];
                    if (wmpobj.Mobile) {
                        var userDatalist = dialog.find('.wmpSingleUserSelector').User("get");
                        if (userDatalist.length > 0) {
                            $(userDatalist).each(function (index, item) {
                                var obj = {};
                                obj.name = item.user_name;
                                obj.no = item.user_no;
                                userData.push(obj);
                            });
                        }
                    } else {
                        var userDatalist = dialog.find('.wmpSingleUserSelector').WmpSelect("get");
                        if (userDatalist.length > 0) {
                            $(userDatalist).each(function (index, item) {
                                var obj = {};
                                obj.name = item.name;
                                obj.no = item.no;
                                userData.push(obj);
                            });
                        }
                    }

                    if (userData.length == 0) {
                        layerTip(window.LangMsg['msg_wmp_recipient_is_not_null']);
                        return;
                    }
                    var operationInfo = {
                    };
                    operationInfo.ApprovedDes = dialog.find('.ApprovedDes').val();
                    if (operationInfo.ApprovedDes) {
                        operationInfo.ApprovedDes =  operationInfo.ApprovedDes.replace(/\n|\r\n/g, "<br>")
                    }
                    if (StringLength(operationInfo.ApprovedDes) > 1000) {
                        dialogOnlyConfirm("沟通原因长度不能超过1000");
                        return;
                    }
                    operationInfo.copyUserlist = userData;
                    wmpobj.AssemblData(butObj, operationInfo);

                });
            }
        });

    }, "GET");
}



///回复沟通
ProcessFlow.prototype.AnswerCommunication = function (butObj) {
    var wmpobj = this;
    AJAX('/Content/Resources/html/AnswerCommunication.html', {
    }, function (d) {
        var html = d;
        var title = window.Lang['text_app_reply_comm'];//'回复沟通'
        var dialog = null;
        layer.open({
            type: 1,
            anim: 'fadeIn',
            title: '<span>' + title + '</span>',
            content: html,
            success: function (layero, index) {
                TransAll(layero);
                dialog = $(layero);
                dialogResize(dialog, 600, 200);
                var index = dialog.attr("index");
                dialog.find("textarea").focus().blur();
                //保存
                dialog.find('.save').click(function () {
                    if (dialog.find('.ApprovedDes').val() == "") {
                        layerTip(window.LangMsg['msg_wmp_reply_content_is_not_null']);
                        return;
                    }
                    var operationInfo = {
                    };
                    operationInfo.ApprovedDes = dialog.find('.ApprovedDes').val();
                    if (operationInfo.ApprovedDes) {
                        operationInfo.ApprovedDes = operationInfo.ApprovedDes.replace(/\n|\r\n/g, "<br>")
                    }
                    if (StringLength(operationInfo.ApprovedDes) > 1000) {
                        dialogOnlyConfirm("回复沟通长度不能超过1000");
                        return;
                    }
                    wmpobj.AssemblData(butObj, operationInfo);
                });
            }
        });
    }, "GET");
}



///取消沟通
ProcessFlow.prototype.CancerCommunication = function (butObj) {
    var wmpobj = this;
    dialogConfirmBox(window.LangMsg['msg_app_sure_cancel_comm'], function (index) {
        wmpobj.AssemblData(butObj);
    });
}
///废弃方法
ProcessFlow.prototype.AbandonOperation = function (butObj) {
    var wmpobj = this;
    AJAX('/Content/Resources/html/AbandonOperation.html', {
    }, function (d) {
        var html = d;
        var title = window.Lang['text_wmp_abandoned_reason'];//'废弃原因';
        var dialog = null;
        layer.open({
            type: 1,
            anim: 'fadeIn',
            title: '<span>' + title + '</span>',
            content: html,
            success: function (layero, index) {
                TransAll(layero);
                dialog = $(layero);
                dialogResize(dialog, 600, 200);
                var index = dialog.attr("index");

                dialog.find("textarea").focus().blur();
                //保存
                dialog.find('.save').click(function () {
                    var operationInfo = {
                    };
                    if (dialog.find('.ApprovedDes').val() == "") {
                        layerTip(window.Lang['text_wmp_abandoned_reason'] + ' ' + window.LangMsg['msg_wmp_not_empty']);
                        return;
                    }
                    operationInfo.ApprovedDes = dialog.find('.ApprovedDes').val();
                    if (operationInfo.ApprovedDes) {
                        operationInfo.ApprovedDes = operationInfo.ApprovedDes.replace(/\n|\r\n/g, "<br>")
                    }
                    if (StringLength(operationInfo.ApprovedDes) > 1000) {
                        dialogOnlyConfirm("废弃原因长度不能超过1000");
                        return;
                    }
                    wmpobj.AssemblData(butObj, operationInfo);
                    ///  layer.close(index);
                });
            }
        });
    }, "GET", false);
}
///流程干预跳转方法
ProcessFlow.prototype.FlowSkip = function (butObj) {
    var wmpobj = this;
    AJAX('/Content/Resources/html/FlowSkip.html', {
    }, function (d) {
        var html = d;
        var title = window.LangMsg['msg_wmp_sponsor_comm'];
        var dialog = null;
        layer.open({
            type: 1,
            anim: 'fadeIn',
            title: '<span>' + title + '</span>',
            content: html,
            success: function (layero, index) {
                TransAll(layero);
                dialog = $(layero);
                dialogResize(dialog, 600, 246);
                var index = dialog.attr("index");
                dialog.find('.wmpSingleUserSelector').WmpSelect("user", { multy: true });
                AJAXAPI('/wmp/api/WMPProc/GetActList', {
                    procInsID: wmpobj.ProcInsID
                }, function (d) {
                    dialog.find('#selNode').html("");
                    var options = "";//"<option  value=''>请选择驳回节点</option>";
                    for (var idex = 0; idex < d.data.length; idex++) {
                        if (d.data[idex]["ActName"] != "流程结束" && d.data[idex]["ActID"] != wmpobj.ActID && d.data[idex]["ActName"] != "起草中" && d.data[idex]["ActName"] != "Start" && d.data[idex]["ActName"] != "start") {
                            var name = (d.data[idex]["ActDisplayName"] == "重新提交" && window.LangType == 'EN') ? "Re-submit" : d.data[idex]["ActDisplayName"];
                            options += "<option value=" + d.data[idex]["ActID"] + ">" + (name == "" ? d.data[idex]["ActName"] : name) + "</option>";
                        }
                    }
                    //dialog.find('.selectReject').append(options).selectpicker();
                    dialog.find('#selNode').append(options).WmpSelectpicker("init");
                }, undefined, undefined, false);
                dialog.find('#selNode').change(function () {
                    if (typeof (Skipfunction) == "function") {
                        if (wmpobj.SkipShowApprovedNodeName == undefined) {
                            dialog.find('.wmpSingleUserSelector').parent().show();
                        } else {
                            if (JSON.stringify(wmpobj.SkipShowApprovedNodeName).indexOf(dialog.find('#selNode').find("option:selected").text()) < 0) {
                                dialog.find('.wmpSingleUserSelector').parent().show();
                            } else {
                                dialog.find('.wmpSingleUserSelector').parent().hide();
                            }
                        }
                    } else {
                        dialog.find('.wmpSingleUserSelector').parent().hide();
                    }
                });

                dialog.find("textarea").focus().blur();
                //保存
                dialog.find('.save').click(function () {
                    if (dialog.find('.ApprovedDes').val() == "") {
                        layerTip(window.LangMsg['msg_wmp_comm_theme_is_not_null']);
                        return;
                    }
                    if (dialog.find("#selNode").val() == "" || dialog.find("#selNode").val() == null) {
                        layerTip(window.LangMsg['msg_mgt_FlowManager_Skip_null']);
                        return;
                    }
                    if (typeof (Skipfunction) == "function") {
                        if (wmpobj.SkipShowApprovedNodeName == undefined) {
                            var result = Skipfunction(dialog.find('#selNode').find("option:selected").text(), dialog.find('.wmpSingleUserSelector').WmpSelect("get"));
                            if (result == false)
                                return;
                        } else {
                            if (JSON.stringify(wmpobj.SkipShowApprovedNodeName).indexOf(dialog.find('#selNode').find("option:selected").text()) < 0) {
                                var result = Skipfunction(dialog.find('#selNode').find("option:selected").text(), dialog.find('.wmpSingleUserSelector').WmpSelect("get"));
                                if (result == false)
                                    return;
                            }
                        }
                    }
                    var operationInfo = {
                    };
                    operationInfo.FApproversUser = wmpobj.FApproversUser;
                    operationInfo.SendBlackActID = dialog.find("#selNode").val();
                    //  operationInfo.SkipNodeName = dialog.find("#selNode").find("option:selected").text();
                    operationInfo.ApprovedDes = dialog.find('.ApprovedDes').val();
                    if (operationInfo.ApprovedDes) {
                        operationInfo.ApprovedDes = operationInfo.ApprovedDes.replace(/\n|\r\n/g, "<br>")
                    }
                    if (StringLength(operationInfo.ApprovedDes) > 1000) {
                        dialogOnlyConfirm("流程干预原因长度不能超过1000");
                        return;
                    }
                    wmpobj.AssemblData(butObj, operationInfo);
                });
            }
        });
    }, "GET");
}
///审计信息查看使用
function filterheight() {
    var win_height = $(window).height();
    var filter_height = win_height - $("#resFilterWrap .filter-title").height();
    $("html").addClass("sn-active");
    $("body").height(win_height);
    $("#resFilterWrap .res-filter-main").height(filter_height);
}
///审计信息查看使用
function removeheight() {
    $("html").removeClass("sn-active");
    $("body").removeAttr("style");
}
function StringLength(str) {
    if (!str) { return 0; }
    return str.replace(/[^\x00-\xff]/g, "01").length;
};
////获取流程流水号
function SetFlowNumBer() {
    AJAXAPI('/processins/getprocinstnumber?bMoudleEN=' + BusinessMoudle + '&bModuleID=' + BusinessModuleID, {}, function (d) {
        $("#Header_formNumber").val(d);
    }, "GET");
}

